perm filename BOOTER.MAC[SCH,LSP] blob sn#688823 filedate 1982-11-14 generic text, type T, neo UTF8
TITLE BOOTER
;;; lets simulate our 360 and do all base-relative addressing
;;; for completely relocatable code.

SEARCH MONSYM
SEARCH MACSYM

AC1=    1
AC2=    2
AC3=    3
AC4=    4
FILES=  12      ;;; ptr into FILETB
RANGES= 13      ;;; ptr into RANGTB
RANGE=  14      ;;; next range for GET
B=      17      ;;; all other relative addressing relative to this

        LOC     1000    ;;; LINK load us into first page even though
START:
                        ;;; we will end up eventually somewhere else.

        ;;; load up our base registers
S:      MOVEI   B,OURADR               ;;; base B contains S:

        ;;; loop over the range table, doing GETs on ourselves.
        ;;; note that GET needs a fresh (non-opened) JFN each time
        ;;; so we really need to do a separate GTJFN each time.
        ;;; duplicate JFNs will disappear (by doing the GET).
    MOVEI   RANGES,RANGTB-S(B)          ;;; get ptr to RANGTB
    MOVEI   FILES,FILETB-S(B)           ;;; get ptr to FILITB
GTLOOP:
    SKIPN   RANGE,(RANGES)              ;;; if next range is null
        JRST    GTEXIT-S(B)                 ;;; then exitloop
    MOVE    AC2,(FILES)                 ;;; get address of file name
    ADDI    AC2,(B)                     ;;; relocate address of name
    HRROI   AC2,(AC2)                   ;;; make into str ptr
    MOVE    AC1,[GJ%SHT+GJ%OLD]-S(B)    ;;; short form, file must exist
    GTJFN                               ;;; get JFN in AC1
        ERJMP   ERROR-S(B)
    HRLI    AC1,.FHSLF                  ;;; GET on JFN into ourself
    TXO     AC1,GT%ADR+GT%NOV           ;;; use range in AC2, no overlap
    MOVE    AC2,RANGE
    GET
        ERJMP   ERROR-S(B)
    AOJ     RANGES,
    AOJA    FILES,GTLOOP-S(B)
GTEXIT:

;;; set our entry vector to be the one we saved
;;;                                            
    MOVEI   AC1,.FHSLF                         
    MOVE    AC2,ENTVEC-S(B)                    
    SEVEC                                      
        ERJMP   ERROR-S(B)                     
                                               
    ;;; load up a program in the ACs that UNMAPs us and start at the old
    ;;; "real" starting address.

    HRLI    AC1,ACPROG-S(B)
    HRRI    AC1,AC3
    BLT     AC1,AC3+ACPLEN-1
    JRST    AC3


ACPROG:                 ;;; AC program to unmap and start at new address
    SETO    AC1,
    HRLI    AC2,.FHSLF
    HRRI    AC2,OURPAG
    SETZ    AC3,
    PMAP
        ERJMP ERROR-S(B)
    RESET
    JRST    OLDSA
ACPEND:
ACPLEN= ACPEND-ACPROG       ;;; length of AC program

    ;;; here if any kind of error occurs
    ;;; print an error message and die.
ERROR:
    HRROI   AC1,[ASCIZ/
?Error in SHARE boot program: /]-S(B)
    PSOUT
    MOVEI   AC1,.PRIOU
    HRLOI   AC2,.FHSLF
    ERSTR
        HALTF
        HALTF
    JRST    .-1-S(B)


    ;;; all tables have one-word entries, and are null terminated.

RANGTB:
      6,, 70
    100,,113
    0
FILETB:
    [ASCIZ/PS:<MACLISP>LISP.EXE.2130/]-S(B)
    [ASCIZ/PS:<MACLISP>LISP.EXE.2130/]-S(B)
    0
OURADR= 74000
OURPAG= 74
ENTVEC: 3003353
OLDSA= 3353
    LIT                 ;;; dump all miscellaneous literals here

    END     START